#include <glib.h>

gint main(gint argc, gchar **argv)
{
    GArray *arr = NULL;
    gint i = 0;
    gint x = 0;
    guint n = 0;
    gint a[3] = {0,0,0};

    arr = g_array_new(FALSE, FALSE, sizeof(gint));
    n = g_array_get_element_size(arr);
    g_print("element size:%d, array len:%d \n", n, arr->len);

    x = 1;
    g_array_append_val(arr, x);
    x = 3;
    g_array_append_val(arr, x);

    n = g_array_get_element_size(arr);
    g_print("element size:%d, array len:%d \n", n, arr->len);

    for(i=0; i<arr->len; i++) {
        g_print("append-val arr[%d]:%d \n", i, g_array_index(arr, gint, i));
    }

    a[0] = 5;
    a[1] = 7;
    g_array_append_vals(arr, a, 2);

    for(i=0; i<arr->len; i++) {
        g_print("append-vals arr[%d]:%d \n", i, g_array_index(arr, gint, i));
    }

    x = 2;
    g_array_prepend_val(arr, x);
    x = 4;
    g_array_prepend_val(arr, x);

    for(i=0; i<arr->len; i++) {
        g_print("prepend-val arr[%d]:%d \n", i, g_array_index(arr, gint, i));
    }

    a[0] = 8;
    a[1] = 6;
    g_array_prepend_vals(arr, a, 2);

    for(i=0; i<arr->len; i++) {
        g_print("prepend-vals arr[%d]:%d \n", i, g_array_index(arr, gint, i));
    }

    x = 9;
    g_array_insert_val(arr, arr->len, x);
    x = 10;
    g_array_insert_val(arr, 0, x);

    for(i=0; i<arr->len; i++) {
        g_print("insert-val arr[%d]:%d \n", i, g_array_index(arr, gint, i));
    }

    a[0] = 12;
    a[1] = 11;
    g_array_insert_vals(arr, 5, a, 2);

    for(i=0; i<arr->len; i++) {
        g_print("insert-vals arr[%d]:%d \n", i, g_array_index(arr, gint, i));
    }
 
    g_array_free(arr, TRUE);

    return 0;
}